﻿using UnityEngine;
using System.Collections;
using System;
using com.gzc.zgxq.game;

public static class DelayToInvokeUtil {

    public static IEnumerator DelayToInvokeDo ( Action action , float delaySeconds ) {
        if (delaySeconds >= 0F) {
            yield return new WaitForSeconds(delaySeconds);
            Util.CallAction(action);
        } else {
            Debuger.LogError("delaySeconds < 0");
        }               
    }

    public static void DelayToInvokeDo (MonoBehaviour compent, string functionName, float delaySeconds) {
        if (!string.IsNullOrEmpty(functionName) && delaySeconds >= 0F) {
            if (!compent.IsInvoking(functionName)) {
                compent.Invoke(functionName, delaySeconds);
            }
        } else {
            Debuger.LogError("functionName is null or empty or delaySeconds < 0");
        }
    }

}
